package com.stylefeng.guns.rest.modular.vo;

import lombok.Data;

import java.io.Serializable;

/**
 * @创建人 lIUJF
 * @创建时间 2019/1/7
 * @描述:
 */
@Data
public class ResponseVO<M> implements Serializable {
	//返回状态
	private int status;
	//返回信息
	private String msg;
	//返回数据实体
	private M data;
	//图片前缀
	private String imgPre;
	//
	private int nowPage;
	//
	private int totalPage;

	private ResponseVO(){
	}


	public static <M> ResponseVO success(M m){
		ResponseVO vo = new ResponseVO();
		vo.setStatus(0);
		vo.setData(m);
		return vo;
	}

	public static <M> ResponseVO success(String imgPre, M m){
		ResponseVO vo = new ResponseVO();
		vo.setStatus(0);
		vo.setData(m);
		vo.setImgPre(imgPre);
		return vo;
	}

	public static <M> ResponseVO success(int nowPage, int totalPage, String imgPre, M m){
		ResponseVO vo = new ResponseVO();
		vo.setStatus(0);
		vo.setData(m);
		vo.setNowPage(nowPage);
		vo.setTotalPage(totalPage);
		vo.setImgPre(imgPre);
		return vo;
	}

	public static <M> ResponseVO success(String msg){
		ResponseVO vo = new ResponseVO();
		vo.setStatus(0);
		vo.setMsg(msg);
		return vo;
	}

	public static <M> ResponseVO serviceFail(String msg){
		ResponseVO vo = new ResponseVO();
		vo.setStatus(1);
		vo.setMsg(msg);
		return vo;
	}

	public static <M> ResponseVO appFail(String msg){
		ResponseVO vo = new ResponseVO();
		vo.setStatus(999);
		vo.setMsg(msg);
		return vo;
	}

}
